package com.example.standard.repository;

import com.example.standard.entity.Standard;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface StandardRepository extends JpaRepository<Standard,Integer>, JpaSpecificationExecutor<Standard> {

    //    修改
    @Modifying
    @Transactional(timeout = 10)
    @Query(value = "UPDATE  standard SET std_num=?1,zhname=?2,version=?3,`keys`=?4,release_date=?5,impl_date=?6,package_path=?7\n" +
            "WHERE id=?8", nativeQuery = true)
    // nativeQuery 表示自然的sql数据库语句，
    // 更新语句的意思是根据id 去更新 状态列，把status改为1.
    int updateStatus(String name,String zhname,String version,String keys,String ksdate,String jsdate,String path,Integer id);  // 定义更新状态的方法，根据id去更新，没有返回值。

    //新增
    @Modifying
    @Transactional(timeout = 10)
    @Query(value = "INSERT INTO `standard` (`std_num`,`zhname`,`version`,`keys`,`release_date`,`impl_date`,package_path) VALUES (?1,?2,?3,?4,?5,?6,?7)", nativeQuery = true)
    void finsdafdsad(String name,String zhname,String version,String keys,String ksdate,String jsdate,String path);


    int countByName(String name);
//    int countByBiaozhunhao(String biaozhunhao);
}
